package com.cqyc.shop.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cqyc.shop.comm.Pager;
import com.cqyc.shop.comm.commException;
import com.cqyc.shop.domain.Shop;
import com.cqyc.shop.services.ShopServices;

@WebServlet(urlPatterns="/oil/grainoil.do")
public class GiainoilLsitServlet extends HttpServlet{
	private static final long serialVersionUID = -1451457540065622616L;
	private Logger logger = LoggerFactory.getLogger(getClass());
	private ShopServices shopServices = new ShopServices();

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	logger.debug("执行从数据库读取操作");
		
		try {
			Shop shop = new Shop();
						
			Pager pager_lyfs = new Pager();
			pager_lyfs.setPageSize(16);
			pager_lyfs.setCurrentPage(1);
			shop.setShopname("粮油");
			
			List<Shop> shops_lyfs = shopServices.findPager(shop,pager_lyfs);

			request.setAttribute("shops_lyfs",shops_lyfs);
			
			
			Pager pager_rmtj = new Pager();
			pager_rmtj.setPageSize(3);
			pager_rmtj.setCurrentPage(7);
			shop.setShopname("粮油");
			
			List<Shop> shops_rmtj = shopServices.findPager(shop,pager_rmtj);

			request.setAttribute("shops_rmtj",shops_rmtj);

			
			logger.debug("查询数据成功");
			request.getRequestDispatcher("/oil/grainoil.jsp").forward(request, response);
		} catch (Exception e) {
			throw new commException("list查找出现异常");
		}
	}
	
	
}
